package marmalius;

import marmalius.craft.firemaking.FireMaking;

public class ItemOnItem {
	
	public void useItem(Player player, int itemUsed, int useWith) {
		if (itemUsed == 590)
			FireMaking.getInstance().startFireMaking(player, useWith);
		else if (useWith == 590)
			FireMaking.getInstance().startFireMaking(player, itemUsed);
	}

    public void useItem(int itemUsed, int useWith, int playerID) {
        client p = (client) PlayerHandler.getInstance().getPlayer(playerID);
        //int Slot = p.inStream.readUnsignedWordA();

        if (useWith == 227 || itemUsed == 227) {
            server.Herblore.unfpot(p.playerId, itemUsed, useWith);
        }
        if (useWith == 946 || itemUsed == 946) {
            server.Fletching.logstobow(itemUsed, useWith, p.playerId);
        }
        if ((useWith == 314 || itemUsed == 314)) {
            server.Fletching.feathertoshaft(itemUsed, useWith, p.playerId);
        }
        if ((useWith == 53 || itemUsed == 53)) {
            server.Fletching.tiptoarrow(itemUsed, useWith, p.playerId);
        }
        if (useWith == 1777 || itemUsed == 1777) {
            server.Fletching.stringbow(itemUsed, useWith, p.playerId);
        }
        if (useWith == 1777 && itemUsed == 6573) {
            if (p.playerLevel[12] >= 90) {
                p.deleteItem(1777, p.getItemSlot(1777), 1);
                p.deleteItem(6573, p.getItemSlot(6573), 1);
                p.addItem(6585, 1);
                p.addSkillXP(550, 13);
                p.sendMessage(
                        "You string the onyx with the string and make a amulet of fury!");
            } else {
                p.sendMessage("You need 90 crafting to do this.");
            }
        }
        if (useWith == 6573 && itemUsed == 1777) {
            if (p.playerLevel[12] >= 90) {
                p.deleteItem(1777, p.getItemSlot(1777), 1);
                p.deleteItem(6573, p.getItemSlot(6573), 1);
                p.addItem(6585, 1);
                p.addSkillXP(550, 13);
                p.sendMessage(
                        "You string the onyx with the string and make a amulet of fury!");
            } else {
                p.sendMessage("You need 90 crafting to do this.");
            }
        }
        if (useWith == 2366 && itemUsed == 2368) {
            if (p.playerLevel[13] >= 90) {
                p.deleteItem(2366, p.getItemSlot(2366), 1);
                p.deleteItem(2368, p.getItemSlot(2368), 1);
                p.addItem(1187, 1);
                p.addSkillXP(550, 13);
                p.sendMessage("You make a Dragon Square Sheild!");
            } else {
                p.sendMessage("You need 90 smithing to do this.");
            }
        }
        if (useWith == 2368 && itemUsed == 2366) {
            if (p.playerLevel[13] >= 90) {
                p.deleteItem(2366, p.getItemSlot(2366), 1);
                p.deleteItem(2368, p.getItemSlot(2368), 1);
                p.addItem(1187, 1);
                p.addSkillXP(550, 13);
                p.sendMessage("You make a Dragon Square Sheild!");
            } else {
                p.sendMessage("You need 90 smithing to do this.");
            }
        }
        if (server.Herblore.isunfpot(useWith)
                || server.Herblore.isunfpot(itemUsed)) {
            server.Herblore.finishpot(p.playerId, itemUsed, useWith);
        } // ----tj007razor: firemaking uses
        // normal logs
        else if (itemUsed == 5354 && useWith == 5312
                || itemUsed == 5312 && useWith == 5354) {
            server.Farming.growSapling(5312, "oak", 5370, p.playerId);
        } else if (itemUsed == 5354 && useWith == 5313
                || itemUsed == 5313 && useWith == 5354) {
            server.Farming.growSapling(5313, "Willow", 5371, p.playerId);
        } else if (itemUsed == 5354 && useWith == 5314
                || itemUsed == 5314 && useWith == 5354) {
            server.Farming.growSapling(5314, "Maple", 5372, p.playerId);
        } else if (itemUsed == 5354 && useWith == 5315
                || itemUsed == 5315 && useWith == 5354) {
            server.Farming.growSapling(5315, "Yew", 5373, p.playerId);
        } else if (itemUsed == 5354 && useWith == 5316
                || itemUsed == 5316 && useWith == 5354) {
            server.Farming.growSapling(5316, "Magic", 5374, p.playerId);
        }

        /* if ((itemUsed == 44 && useWith == 52)
         || (useWith == 44 && itemUsed == 52)) {   
         p.doFletch(1000, 80, 44, 15, 52, 15, 892, 15);
         }
         if ((itemUsed == 43 && useWith == 52)
         || (useWith == 43 && itemUsed == 52)) {   
         p.doFletch(900, 70, 43, 15, 52, 15, 890, 15);
         }
         if ((itemUsed == 42 && useWith == 52)
         || (useWith == 42 && itemUsed == 52)) {   
         p.doFletch(800, 60, 42, 15, 52, 15, 888, 15);
         }
         if ((itemUsed == 41 && useWith == 52)
         || (useWith == 41 && itemUsed == 52)) {   
         p.doFletch(700, 50, 41, 15, 52, 15, 886, 15);
         }
         if ((itemUsed == 40 && useWith == 52)
         || (useWith == 40 && itemUsed == 52)) {   
         p.doFletch(600, 40, 40, 15, 52, 15, 884, 15);
         }
         if ((itemUsed == 39 && useWith == 52)
         || (useWith == 39 && itemUsed == 52)) {   
         p.doFletch(500, 80, 39, 15, 52, 15, 882, 15);
         }*/
        
        /*
        if ((itemUsed == 590 && useWith == 1511) || (useWith == 590 && itemUsed == 1511)) {
            p.doFires(100, 0, 1511);
        }
        // oak logs
        if ((itemUsed == 590 && useWith == 1521) || (useWith == 590 && itemUsed == 1521)) {
            p.doFires(400, 15, 1521);
        }
        // willow logs
        if ((itemUsed == 590 && useWith == 1519) || (useWith == 590 && itemUsed == 1519)) {
            p.doFires(700, 30, 1519);
        }
        // maple logs
        if ((itemUsed == 590 && useWith == 1517) || (useWith == 590 && itemUsed == 1517)) {
            p.doFires(1000, 45, 1517);
        }
        // yew logs
        if ((itemUsed == 590 && useWith == 1515)
                || (useWith == 590 && itemUsed == 1515)) {
            p.doFires(1300, 60, 1515);
        }
        // magic logs
        if ((itemUsed == 590 && useWith == 1513)
                || (useWith == 590 && itemUsed == 1513)) {
            p.doFires(1700, 75, 1513);
        }
        */
        // ----end firemaking
        if ((p.playerName != null || p.playerName != "null")) {
            if (itemUsed == 1733 && useWith == 1741) {
                if (p.playerLevel[12] >= 0) {
                    p.showInterface(2311);
                } 
            } else if (itemUsed == 1733 && useWith == 1743) {
                if (p.playerLevel[12] >= 1) {
                    p.deleteItem(1743, p.getItemSlot(1743), 1);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addItem(1131, 1);
                    p.addSkillXP(155, 12);
                    p.sendMessage("You make a HardLeather Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 1 hardleather & 1 crafting to make this.");
                }
            } else if (itemUsed == 1741 && useWith == 1733) {
                if (p.playerLevel[12] >= 0) {
                    p.showInterface(2311);
                }
            } else if (itemUsed == 1743 && useWith == 1733) {
                if (p.playerLevel[12] >= 2) {
                    p.deleteItem(1743, p.getItemSlot(1743), 1);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addItem(1131, 1);
                    p.addSkillXP(550, 12);
                    p.sendMessage("You make a HardLeather Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 1 hardleather & 1 crafting to make this.");
                }
            } else if (itemUsed == 1745 && useWith == 1733) {
                if (p.playerLevel[12] >= 30) {
                    p.addItem(1099, 1);
                    p.deleteItem(1745, p.getItemSlot(1745), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(700, 12);
                    p.sendMessage("You make a Green d'hide chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 greenhides & 30 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 1745) {
                if (p.playerLevel[12] >= 30) {
                    p.addItem(1099, 1);
                    p.deleteItem(1745, p.getItemSlot(1745), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(700, 12);
                    p.sendMessage("You make a Green d'hide chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 greenhides & 30 crafting to make this.");
                }
            } else if (itemUsed == 1753 && useWith == 1733) {
                if (p.playerLevel[12] >= 50) {
                    p.addItem(1135, 1);
                    p.deleteItem(1753, p.getItemSlot(1753), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1000, 12);
                    p.sendMessage("You make a Green d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 greenhides & 50 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 1753) {
                if (p.playerLevel[12] >= 50) {
                    p.addItem(1135, 1);
                    p.deleteItem(1753, p.getItemSlot(1753), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1000, 12);
                    p.sendMessage("You make a Green d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 greenhides & 50 crafting to make this.");
                }
            } else if (itemUsed == 2505 && useWith == 1733) {
                if (p.playerLevel[12] >= 55) {
                    p.addItem(2493, 1);
                    p.deleteItem(2505, p.getItemSlot(2505), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1500, 12);
                    p.sendMessage("You make a Blue d'hide Chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 Bluehides & 55 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 2505) {
                if (p.playerLevel[12] >= 55) {
                    p.addItem(2493, 1);
                    p.deleteItem(2505, p.getItemSlot(2505), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1050, 12);
                    p.sendMessage("You make a Blue d'hide Chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 Bluehides & 55 crafting to make this.");
                }
            } else if (itemUsed == 1751 && useWith == 1733) {
                if (p.playerLevel[12] >= 60) {
                    p.addItem(2499, 1);
                    p.deleteItem(1751, p.getItemSlot(1751), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1200, 12);
                    p.sendMessage("You make a Blue d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 Bluehides & 60 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 1751) {
                if (p.playerLevel[12] >= 60) {
                    p.addItem(2499, 1);
                    p.deleteItem(1751, p.getItemSlot(1751), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1200, 12);
                    p.sendMessage("You make a Blue d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 Bluehides & 60 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 2507) {
                if (p.playerLevel[12] >= 65) {
                    p.addItem(2495, 1);
                    p.deleteItem(2507, p.getItemSlot(2507), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1400, 12);
                    p.sendMessage("You make a red d'hide Chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 Redhides & 65 crafting to make this.");
                }
            } else if (itemUsed == 2507 && useWith == 1733) {
                if (p.playerLevel[12] >= 65) {
                    p.addItem(2495, 1);
                    p.deleteItem(2507, p.getItemSlot(2507), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1400, 12);
                    p.sendMessage("You make a red d'hide Chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 Redhides & 65 crafting to make this.");
                }
            } else if (itemUsed == 1749 && useWith == 1733) {
                if (p.playerLevel[12] >= 75) {
                    p.addItem(2501, 1);
                    p.deleteItem(1749, p.getItemSlot(1749), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1500, 12);
                    p.sendMessage("You make a red d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 Redhides & 75 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 1749) {
                if (p.playerLevel[12] >= 75) {
                    p.addItem(2501, 1);
                    p.deleteItem(1749, p.getItemSlot(1749), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1600, 12);
                    p.sendMessage("You make a red d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 Redhides & 75 crafting to make this.");
                }
            } else if (itemUsed == 2509 && useWith == 1733) {
                if (p.playerLevel[12] >= 85) {
                    p.addItem(2497, 1);
                    p.deleteItem(2509, p.getItemSlot(2509), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1700, 12);
                    p.sendMessage("You make a black d'hide Chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 Blackhides & 85 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 2509) {
                if (p.playerLevel[12] >= 85) {
                    p.addItem(2497, 1);
                    p.deleteItem(2509, p.getItemSlot(2509), 3);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(1700, 12);
                    p.sendMessage("You make a black d'hide Chaps!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 3 Blackhides & 85 crafting to make this.");
                }
            } else if (itemUsed == 1747 && useWith == 1733) {
                if (p.playerLevel[12] >= 95) {
                    p.addItem(2503, 1);
                    p.deleteItem(1747, p.getItemSlot(1747), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(2000, 12);
                    p.sendMessage("You make a black d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 Blackhides & 95 crafting to make this.");
                }
            } else if (itemUsed == 1733 && useWith == 1747) {
                if (p.playerLevel[12] >= 95) {
                    p.addItem(2503, 1);
                    p.deleteItem(1747, p.getItemSlot(1747), 5);
                    p.deleteItem(1733, p.getItemSlot(1733), 1);
                    p.addSkillXP(2000, 12);
                    p.sendMessage("You make a black d'hide Body!");
                } else {
                    p.sendMessage(
                            "You need 1 Thread, 5 Blackhides & 95 crafting to make this.");
                }
            }
            // end Crafting - Sam Server
			
				


            
            // firemaking
			

            // flec(woodSlot);
            // herblore shit!
            // grinding

            if (itemUsed == 233 && useWith == 237) {
                p.deleteItem(237, p.getItemSlot(237), 1);
                p.addItem(235, 1);
            } else if (itemUsed == 237 && useWith == 233) {
                p.deleteItem(237, p.getItemSlot(237), 1);
                p.addItem(235, 1);
            } else if (itemUsed == 233 && useWith == 243) {
                p.deleteItem(243, p.getItemSlot(243), 1);
                p.addItem(241, 1);
            } else if (itemUsed == 243 && useWith == 233) {
                p.deleteItem(243, p.getItemSlot(243), 1);
                p.addItem(241, 1);
            } else if (itemUsed == 233 && useWith == 1973) {
                p.deleteItem(1973, p.getItemSlot(1973), 1);
                p.addItem(1975, 1);
            } else if (itemUsed == 1973 && useWith == 233) {
                p.deleteItem(1973, p.getItemSlot(1973), 1);
                p.addItem(1975, 1);
            } // end grinding
            // herbs and vial of water to unpots
            // end UnPots and 2nd Ing to Pot
            // end herblore shit!
            else if (itemUsed == 1511 && useWith == 946) {
                if (p.playerLevel[9] >= 0) {
                    p.deleteItem(1511, p.getItemSlot(1511), 1);
                    p.addItem(50, 1);
                    p.addSkillXP(15, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 0 to make this bow.");
                }
            } else if (itemUsed == 1521 && useWith == 946) {
                if (p.playerLevel[9] >= 20) {
                    p.deleteItem(1521, p.getItemSlot(1521), 1);
                    p.addItem(54, 1);
                    p.addSkillXP(25, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 20 to make this bow.");
                }
            } else if (itemUsed == 1519 && useWith == 946) {
                if (p.playerLevel[9] >= 40) {
                    p.deleteItem(1519, p.getItemSlot(1519), 1);
                    p.addItem(60, 1);
                    p.addSkillXP(40, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 40 to make this bow.");
                }
            } else if (itemUsed == 1517 && useWith == 946) {
                if (p.playerLevel[9] >= 60) {
                    p.deleteItem(1517, p.getItemSlot(1517), 1);
                    p.addItem(64, 1);
                    p.addSkillXP(65, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 60 to make this bow.");
                }
            } else if (itemUsed == 1515 && useWith == 946) {
                if (p.playerLevel[9] >= 75) {
                    p.deleteItem(1515, p.getItemSlot(1515), 1);
                    p.addItem(68, 1);
                    p.addSkillXP(90, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 75 to make this bow.");
                }
            } else if (itemUsed == 1513 && useWith == 946) {
                if (p.playerLevel[9] >= 90) {
                    p.deleteItem(1513, p.getItemSlot(1513), 1);
                    p.addItem(72, 1);
                    p.addSkillXP(120, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 90 to make this bow.");
                }
            } // ------------------------end of cutting--------------------------------
            else if (itemUsed == 50 && useWith == 1777) {
                if (p.playerLevel[9] >= 0) {
                    p.deleteItem(50, p.getItemSlot(50), 1);
                    p.deleteItem(1777, p.getItemSlot(1777), 1);
                    p.addItem(841, 1);
                    p.addSkillXP(15, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 0 to make this bow.");
                }
            } else if (itemUsed == 54 && useWith == 1777) {
                if (p.playerLevel[9] >= 20) {
                    p.deleteItem(54, p.getItemSlot(54), 1);
                    p.deleteItem(1777, p.getItemSlot(1777), 1);
                    p.addItem(843, 1);
                    p.addSkillXP(25, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 20 to make this bow.");
                }
            } else if (itemUsed == 60 && useWith == 1777) {
                if (p.playerLevel[9] >= 40) {
                    p.deleteItem(60, p.getItemSlot(60), 1);
                    p.deleteItem(1777, p.getItemSlot(1777), 1);
                    p.addItem(849, 1);
                    p.addSkillXP(40, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 40 to make this bow.");
                }
            } else if (itemUsed == 64 && useWith == 1777) {
                if (p.playerLevel[9] >= 60) {
                    p.deleteItem(64, p.getItemSlot(64), 1);
                    p.deleteItem(1777, p.getItemSlot(1777), 1);
                    p.addItem(853, 1);
                    p.addSkillXP(65, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 60 to make this bow.");
                }
            } else if (itemUsed == 68 && useWith == 1777) {
                if (p.playerLevel[9] >= 75) {
                    p.deleteItem(68, p.getItemSlot(68), 1);
                    p.deleteItem(1777, p.getItemSlot(1777), 1);
                    p.addItem(857, 1);
                    p.addSkillXP(90, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 75 to make this bow.");
                }
            } else if (itemUsed == 72 && useWith == 1777) {
                if (p.playerLevel[9] >= 90) {
                    p.deleteItem(72, p.getItemSlot(72), 1);
                    p.deleteItem(1777, p.getItemSlot(1777), 1);
                    p.addItem(861, 1);
                    p.addSkillXP(120, 9);
                } else {
                    p.sendMessage(
                            "You need a fletching level of 90 to make this bow.");
                }
            } else if (itemUsed == 1755 && useWith == 1625) {
                p.ACraftGemMain(1, 1625, 50, 1609, "Opal");
            } else if (itemUsed == 1755 && useWith == 1627) {
                p.ACraftGemMain(13, 1627, 100, 1611, "Jade");
            } else if (itemUsed == 1755 && useWith == 1629) {
                p.ACraftGemMain(16, 1629, 125, 1613, "Red Topaz");
            } else if (itemUsed == 1755 && useWith == 1623) {
                p.ACraftGemMain(27, 1623, 175, 1605, "Emerald");
            } else if (itemUsed == 1755 && useWith == 1619) {
                p.ACraftGemMain(34, 1619, 190, 1603, "Ruby");
            } else if (itemUsed == 1755 && useWith == 1617) {
                p.ACraftGemMain(43, 1617, 200, 1601, "Diamond");
            } else if (itemUsed == 1755 && useWith == 1631) {
                p.ACraftGemMain(55, 1631, 210, 1615, "Dragonstone");
            } else if (itemUsed == 1755 && useWith == 6571) {
                p.ACraftGemMain(67, 6571, 220, 6573, "Onyx");
            }
            // end of fletching--------------------------------------
        }
    }
}
